//
// Created by wang on 2021/7/4.
//

#ifndef ENET_ERR_H
#define ENET_ERR_H

#include "cmn.h"
#include "enet.h"
#include "er.h"

#define ENET_RET_SUCCESS 0
#define ERR_PROC_MAX_DESC_LEN 64


typedef struct {
    uint32_t code;
    char desc[ERR_PROC_MAX_DESC_LEN];
}err_proc;

#define ERR_UNREGISTERED 0
#define ERR_REGISTERED 1

typedef struct {
    uint8_t reg_flag;
    err_proc *proc;
}err_module;

void err_init();
uint32_t err_register(uint8_t, err_proc *);
uint32_t err_register_all();
char* err_to_str(uint32_t, char *);

#if defined(DEBUG_ERR)
extern uint32_t dbg_g_err_arr[ERR_MAX_ERR];
extern err_proc dbg_g_err_proc_all[ERR_MAX_ERR];
#endif

#endif //ENET_ERR_H
